from django.db import models

class Company(models.Model):
    record_id = models.IntegerField()
    name = models.CharField(max_length=256)
    
class Driver(models.Model):
    name = models.CharField(max_length=256)

class Sale(models.Model):
    TEMPERATURE_CHOICES = (
        ('H', 'Hot'),
        ('C', 'Cold'),
        ('R', 'Reheat'),
    )

    STATUS_CHOICES = (
        ('N', 'Not Exported'),
        ('U', 'Not Updated'),
        ('E', 'Exported'),
    )
    
    company = models.ForeignKey(Company)
    delivery_add1 = models.CharField(max_length=256)
    delivery_add2 = models.CharField(max_length=256)
    invoice = models.IntegerField()
    entry_date = models.DateTimeField('date entered')
    due_date = models.DateField('date due')
    due_time = models.TimeField('time due')
    leaving_time = models.TimeField('time leaving')
    temperature = models.CharField(max_length=2, choices=TEMPERATURE_CHOICES)
    ordered_by = models.CharField(max_length=256)
    on_site_contact = models.CharField(max_length=256)
    status = models.CharField(max_length=2, choices=STATUS_CHOICES)
    driver = models.ForeignKey(Driver)


class Item(models.Model):
    SECTION_CHOICES = (
        ('SV', 'Savoury'),
        ('SW', 'Sandwich'),
        ('FR', 'Fruit'),
        ('SW', 'Sweet'),
        ('DR', 'Drivers'),
    )

    SUB_SECTION_CHOICES = (
        ('', ''),
        ('', ''),
        ('', ''),
    )

    MENU_CHOICES = (
        ('C', 'Canape'),
        ('B', 'Buffet'),
        ('F', 'Finger Food'),
    )

    SUB_MENU_CHOICES = (
        ('', ''),
        ('', ''),
        ('', ''),
    )

    ROLE_CHOICES = (
        ('', ''),
        ('', ''),
    )

    TEMPERATURE_CHOICES = (
        ('H', 'Hot'),
        ('C', 'Cold'),
    )

    code = models.CharField(max_length=32)
    description = models.CharField(max_length=256)
    section =  models.CharField(max_length=2, choices=SECTION_CHOICES)
    sub_section = models.CharField(max_length=2, choices=SUB_SECTION_CHOICES)
    menu = models.CharField(max_length=2, choices=MENU_CHOICES)
    sub_menu = models.CharField(max_length=2, choices=SUB_MENU_CHOICES)
    role = models.CharField(max_length=2, choices=ROLE_CHOICES)
    temperature = models.CharField(max_length=2, choices=TEMPERATURE_CHOICES)

class Item_Instance(models.Model):
    item = models.ForeignKey(Item)
    sale = models.ForeignKey(Sale)
    quantity = models.IntegerField()
    custom_description = models.CharField(max_length=256)


